<template>
	<view class="container">

		<scroll-view class="section" scroll-y="true" :style="{height: wh+'px'}">
			<view class="section-item pd100">

				<!-- <view class="item flex flex-start">
					<view class="key">商品图片:</view>
					<view class="ml30 flex flex-justify-start image-box">
						<upload ref="upload" :uploadParams="{goodsid: goodsid,imagevalue}"></upload>
					</view>
				</view> -->
				<!-- <view class="line"></view> 
				<view class="item flex u-row-left">
					<view class="key">商品分类:</view>
					<view class="ml30 typeselectbox">
						<uni-data-select v-model="rangevalue" placeholder="请选择品类" :localdata="range"
							@change="change"></uni-data-select>
						<view class="icon">
							<image src="/static/images/home/icon_select.png"></image>
						</view>
					</view>
				</view> -->
				<view class="item flex space-between">
					<view class="key">商品名称:</view>
					<input class="value" v-model="goodsname" focus="true" maxlength="10"
						@blur="goodsname=goodsname.replace(/[^\u4E00-\u9FA5|\d|\a-zA-Z|\r\n\s,.?!，。？！…—&$=()-+/*{}[\]]/g, '')"
						@input="namecheck($event)" placeholder-class="placeholder" placeholder="请输入商品名称" />
				</view>
				<view class="" style="position: relative;">
					<textarea name="" style="width: 100%;margin-left: 0rpx !important;" id=""
						:disable-default-padding="true" maxlength="50" :auto-height="true" class="value"
						v-model="goodsdetail" @input="descInput($event)"
						@blur="goodsdetail=goodsdetail.replace(/[^\u4E00-\u9FA5|\d|\a-zA-Z|\r\n\s,.?!，。？！…—&$=()-+/*{}[\]]/g, '')"
						placeholder-class="placeholder" placeholder="请简要介绍您的商品..."
						placeholder-style="text-align:left"></textarea>
					<view class="show_number">
						{{remnant}}/50
					</view>
				</view>
				<view class="item" style="background: #f8f8fe;">
					<view class="ml30 flex flex-justify-start image-box">
					<upload ref="upload" :uploadParams="{goodsid: goodsid,imagevalue}"></upload>
					</view>
				</view>
				<view class="item flex u-row-left  space-between">
					<view class="key">商品模式:</view>
					<view class="ml30 typeselectbox">
						<uni-data-select v-model="productModelValue" placeholder="共享商品" :localdata="productModelList"
							@change="changeProductModel"></uni-data-select>
						<view class="icon">
							<image src="/static/images/home/icon_select.png"></image>
						</view>
					</view>
					<uni-icons type="help-filled" size="20" color="#9AB4CA" @click="showPopup = true"></uni-icons>
				</view>
				<view class="item flex u-row-left  space-between">
					<view class="key"> 价格:</view>
					<view class="flex value-box">
						<input class="value" v-model="money" focus="true" minlength="1" maxlength="7" @blur=""
							type="number" placeholder-class="placeholder" :disabled="productModelValue !== 2"
							:placeholder="productModelValue === 2 ? '请输入' : ''" />
						<text>{{productModelValue !== 2 ? '金币' : '元' }}</text>
					</view>

				</view>
				<view class="line"></view>
				<view class="item flex space-between">
					<view class="key">我的位置:</view>
					<view class="addressbox ml30">

						<textarea name="" id="" :disabled="true" class="position-address"
							:disable-default-padding="true" :auto-height="true" v-model="location.address"
							placeholder="地址" placeholder-style="text-align:left" maxlength="100"></textarea>
					</view>
				</view>
				<view class="locationbtn">
					<view>
						<text class="distance">为保证您的隐私安全，此处不可更改仅展示大概位置</text>

					</view>

					<button type="primary" size="mini" @click="locationClick">更新定位</button>
				</view>
				<!-- <view class="item flex space-between">
					<view class="key">订单状态实时通知:</view>
					<view class="value">
						<radio-group @change="radioChange">
							<label class="radio">
								<radio color="#6C64D0" value="true" checked="true" />是
							</label>
							<label class="radio">
								<radio color="#6C64D0" value="false" />否
							</label>
						</radio-group>
					</view>
				</view> -->


				<!-- 			 <view class="contentCheckBox">
					<view>审核需等几秒</view>
					<view class="checkbox">
						<u-checkbox-group placement="row">
							<u-checkbox activeColor="green" shape="circle" label="文字审核通过" :checked="textcheck"></u-checkbox>
							<u-checkbox :customStyle="{marginLeft: '20px'}" activeColor="green" shape="circle" label="图片审核通过" :checked="imagecheck"></u-checkbox>
						</u-checkbox-group>
						<button type="primary" size="mini" @click="checkClick">内容违规审核</button>
					</view>

				 </view> -->
			</view>
		</scroll-view>


		<!-- 底部按钮 start -->
		<view class="btn-box w100 fixed">
			<button class="btn btn-save" :disabled="!isclick" type="primary" @click="btnOkClick">发布</button>
		</view>
		<!-- 底部按钮 end -->

		<u-popup :show="showPopup" mode="center" @close="showPopup = false" :customStyle="{'borderRadius': '20rpx'}">
			<view class="popup">
				<view class="titles">{{ productModelValue === 1 ? '共享细则': '售卖细则' }}</view>
				<image src="/static/images/home/close.png" mode="widthFix" @click="showPopup = false"></image>
				<text class="content"
					v-if="productModelValue === 1">凡在共享圈上架的物品，均为一金币，这里不分高低贵贱，只有需要和不需要，上架的物品被买家购买则获取一金币，购买他人商品则花费一金币。</text>
				<text class="content"
					v-else>凡在售卖圈上架的物品，由您自己定价，平台不收取任何佣金和差价，买家下单后需要与卖家协商线下交易地点，双方确认货物没问题则点击完成交易，输入对方的交易码，若不满意，则点击取消订单。</text>
			</view>
		</u-popup>
		<u-popup :show="showPopupOrder" mode="center" @close="showPopupOrder = false"
			:customStyle="{'borderRadius': '20rpx'}">
			<view class="popup">
				<view class="item flex space-between">
					<view class="key" style="font-size: 24rpx;">订单状态实时通知:</view>
					<view class="value">
						<radio-group @change="radioChange">
							<label class="radio">
								<radio color="#6C64D0" value="true" checked="true" />是
							</label>
							<label class="radio">
								<radio color="#6C64D0" value="false" />否
							</label>
						</radio-group>
					</view>
				</view>
				<view class="btn-save sure" style="margin-top: 20rpx;text-align: center;" @click="btnOkClickSure">确定
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	var self
	import QQMapWX from '../../utils/qqmap-wx-jssdk'
	// import mpImageCompress from 'mp-image-compress'
	import upload from '@/components/upload.vue'
	const COS = require('cos-wx-sdk-v5');

	var qqmapsdk;
	export default {
		components: {
			upload
		},
		data() {
			return {
				showPopup: false,
				showPopupOrder: false, // 订单是否提醒
				mediaUrl: uni.$http.mediaUrl,
				wh: 0,
				remnant: "0",
				istui: true,
				goodsid: '',
				goodsname: '',
				money: '1',
				goodscoins: '',
				goodsdetail: '',
				sizeType: ['compressed'],
				limitType: ['png', 'jpg', 'jpeg'],
				fileMaxSize: 1 * 1024 * 1024,
				maxSize: 20 * 1024 * 1024,
				fileMinSize: 5 * 1024,
				fileList: [],
				fileList1: [],
				imagevalue: '',

				rangevalue: '',
				productModelList: [{
					value: 1,
					text: '共享商品'
				}, {
					value: 2,
					text: '售卖商品'
				}],
				productModelValue: 1,
				range: [{
						value: 0,
						text: "家用电器"
					}, {
						value: 1,
						text: "数码设备"
					}, {
						value: 2,
						text: "电脑办公"
					},
					{
						value: 3,
						text: "家具"
					}, {
						value: 4,
						text: "图书"
					}, {
						value: 5,
						text: "母婴玩具"
					},
					{
						value: 6,
						text: "服饰"
					}, {
						value: 7,
						text: "美妆"
					}, {
						value: 8,
						text: "食品"
					},
					{
						value: 9,
						text: "其他"
					}
				],
				typevalue: '其他',

				userInfo: uni.getStorageSync('userInfo') || null,
				location: {
					latitude: 33.002883,
					longitude: 112.491943,
					address: '中国'
				},
				// 陈大大 30.27764133029514 120.15450113932292 浙江省杭州市拱墅区湖墅南路
				login_code: '',
				openid: '',
				access_token: '',
				checkresult: '没有经过审核',
				textcheck: false,
				imagecheck: false,
				traceidList: [],
				timer: '',
				isclick: true,
			};
		},
		onLoad(e) {

			// 被冻结账号直接抬走

			if (!uni.getStorageSync('is_active')) {
				uni.showToast({
					title: '该账号已被冻结，有疑问请联系客服',
					icon: 'none',
					duration: 2000
				})
				// setTimeout(() => {
				// 	uni.reLaunch({
				// 		url: '/pages/mine/mine'
				// 	})
				// }, 2000);
			}


			// mpImageCompress.clearTempImg()
			self = this

			if (e.goodsid) {
				this.goodsid = e.goodsid
				//证明是编辑过来的。先去查出来
				this.cha()

			} else {
				this.goodsid = new Date().getTime();
				self.getAuthorizeInfo()

			}
			const sysInfo = uni.getSystemInfoSync()
			this.wh = sysInfo.windowHeight - 60
		},
		onShow() {
			self = this
			uni.login({
				provider: 'weixin',
				async success(res) {
					self.login_code = res.code;
					const postmsg = {
						login_code: self.login_code
					}
					const {
						data: ress
					} = await uni.$http.post('wxGetOpenId/', postmsg)
					if (ress.code == 200) {
						self.openid = ress.data.openid
						self.access_token = ress.data.access_token
					} else {
						console.log(ress.msg)
					}
				}
			})

			this.isclick = true
			qqmapsdk = new QQMapWX({
				key: this.wemapkey
			});

			console.log(self.location)

			// uni.login({
			// 	provider: 'weixin',
			// 	async success(res) {
			// 		self.login_code = res.code;
			// 		const postmsg = {
			// 			login_code: self.login_code
			// 		}
			// 		const {
			// 			data: ress
			// 		} = await uni.$http.post('wxGetOpenId/', postmsg)
			// 		if (ress.code == 200) {
			// 			self.openid = ress.data.openid
			// 			self.access_token = ress.data.access_token
			// 			// console.log('openid+access_token---',self.openid,self.access_token)
			// 		} else {
			// 			console.log(ress.msg)
			// 		}
			// 	}
			// })
		},
		// onUnload() {
		//     mpImageCompress.clearTempImg()  // 页面卸载时清除临时文件
		//   },
		methods: {
			changeProductModel(e) {
				this.productModelValue = e
				if (e === 1) {
					this.money = '1'
				} else {
					this.money = ''
				}
			},
			// uploadImg() {
			// 	uni.chooseImage({
			// 		count: 6, // 一次选择的图片数量
			// 		sizeType: ['original', 'compressed'], // 原图或压缩图
			// 		sourceType: ['album', 'camera'], // 图片来源
			// 		success: (res) => {
			// 			console.log(res.tempFiles)
			// 			const cos = new COS({
			// 				SecretId: 'AKIDDKRWo9cAkIvz0ptpZFl4sjUD55xdJrW7',
			// 				SecretKey: 'd5LRK1WotmU0JiDYhePyKfp5KPL9mJhu',
			// 			});
			// 			res.tempFiles.forEach(file => {
			// 				const filePath = file.path
			// 				uni.getFileSystemManager().readFile({
			// 					filePath: filePath,
			// 					success: (res) => {
			// 						cos.putObject({
			// 							Bucket: 'lyg-1254016590', // 存储桶名称
			// 							Region: 'ap-nanjing', // 区域
			// 							Key: '/goods/' + Date.now() + '-' + Math
			// 								.random().toString(36).substr(2,
			// 								8), // 文件路径及名称
			// 							Body: res.data,
			// 							onProgress: (progressData) => {
			// 								console.log('进度:', JSON.stringify(
			// 									progressData));
			// 							}
			// 						}, (err, data) => {
			// 							if (err) {
			// 								console.error('上传失败:', err);
			// 							} else {
			// 								console.log('上传成功:', data);
			// 								this.fileList1.push({
			// 									url: 'https://' + data
			// 										.Location
			// 								})
			// 							}
			// 						});
			// 					},
			// 					fail: (error) => {
			// 						console.error('读取文件失败:', error);
			// 					}
			// 				});
			// 			})
			// 		},
			// 	})
			// },
			// // 文字检测
			checkText(content) {
				uniCloud.callFunction({
					name: 'hellocf',
					data: {
						content: content,
						openid: uni.getStorageSync('openid'),
						scene: 2,
						version: 2
					},
					success(res) {
						if (res.result.errCode !== 0) {
							return uni.showToast({
								title: `涉嫌 ${res.result.result.label}，请文明用语`,
								icon: 'none',
								duration: 2000
							})
						}
					},
					fail(err) {
						console.log(`请求服务失败，详细错误信息为：${err}`);
					}
				})
			},
			// 图片检测
			checkImageV2(url) {
				uniCloud.callFunction({
					name: 'hellocf',
					data: {
						image: url,
						mediaType: 'image',
						openid: uni.getStorageSync('openid'),
						scene: 1,
						version: 2
					},
					success(res) {
						if (res.result.errCode) {
							uni.showModal({
								content: res.result.errMsg,
								showCancel: false
							})

						} else if (res.result.errCode === 0) {
							console.log(`traceId: ${res.result.traceId}`);
						}
					},
					fail(err) {
						console.log(`请求服务失败，详细错误信息为：${err}`);
					}
				})
			},
			namecheck(e) {
				console.log(this.goodsname)
				// this.goodsname=e.detail.value.substring(0,19)

				// 内容安全检测
				if (this.goodsname.length >= 10) {

					// console.log(this.goodsname)
					return uni.showToast({
						title: '商品名请保持在10字以内',
						icon: 'none',
						duration: 2000
					})
				} else {
					// this.checkText(e.detail.value)
					this.txtyanzheng("name", this.goodsname)

				}


			},

			descInput(e) {
				// var lao = e.detail.value
				// console.log(lao)

				// var xin = e.detail.value.replace(/[^\u4E00-\u9FA5|\d|\a-zA-Z|\r\n\s,.?!，。？！…—&$=()-+/*{}[\]]/g, '')
				// console.log(xin)

				// if (lao != xin) {
				// 	uni.showToast({
				// 		title: '抱歉不可添加特殊符号',
				// 		icon: 'none',
				// 		duration: 2000
				// 	})
				// 	this.goodsdetail = xin
				// 	console.log(this.goodsdetail)

				// }

				this.remnant = this.goodsdetail.length

				if (this.remnant > 49) {
					uni.showToast({
						title: '超出了字数限制',
						icon: 'error',
						duration: 1000
					})

				} else {
					if (this.remnant > 0) {
						this.txtyanzheng("neirong", this.goodsdetail)

					}


				}
			},
			async txtyanzheng(type, msg) {
				const postmsg = {
					openid: self.openid,
					access_token: self.access_token,
					msg: msg,
					type: 'fabu'
				}
				const {
					data: res
				} = await uni.$http.post('textMsgCheck/', postmsg)
				if (res.code == 200) {
					// console.log(res.msg)

				} else {
					uni.showToast({
						icon: 'error',
						title: res.msg,
						duration: 2000
					});
					// if (type == 'name') {
					// 	this.goodsname = ''
					// } lse {
						// ds
					this.goodsdetail = ''
					this.remnant = 0

					// }
					// console.log(res.msg)
				}
			},
			// radioChange(evt) {
			// 	this.istui = evt.detail.value
			// 	console.log(this.istui)
			// },
			//文件大小超出限制
			oversize() {
				uni.showToast({
					title: "抱歉图片最大不能超过20M",
					icon: 'none'
				})
			},

			// change(e) {
			// 	this.rangevalue = e
			// 	let obj = this.range.find((i) => { //listData就是上面的数据源
			// 		return i.value === e; //筛选出匹配数据
			// 	});
			// 	this.typevalue = obj.text
			// },
			changetest(e) {
				this.typevalue = e
				let obj = this.range.find((i) => { //listData就是上面的数据源
					return i.text === e; //筛选出匹配数据
				});
				this.rangevalue = obj.value
				console.log(this.rangevalue, this.typevalue)
			},


			// 位置授权
			getAuthorizeInfo() {
				uni.authorize({
					scope: 'scope.userLocation',
					success() { // 允许授权
						self.getLocationInfo();
					},
					fail() { // 拒绝授权
						self.openConfirm();
						// console.log("你拒绝了授权，无法获得周边信息")
					}
				})
			},
			// 再次获取授权，当用户第一次拒绝后再次请求授权
			openConfirm() {
				uni.showModal({
					title: '请求授权当前位置',
					content: '需要获取您的地理位置，请确认授权',
					success: (res) => {
						if (res.confirm) {
							uni.openSetting(); // 打开地图权限设置
						} else if (res.cancel) {
							uni.showToast({
								title: '你拒绝了授权，无法获得周边信息',
								icon: 'none',
								duration: 1000
							})
						}
					}
				});
			},
			// 位置授权成功后，自动获取地理位置经纬度
			getLocationInfo() {
				uni.getLocation({
					type: 'gcj02',
					success(res) {
						// 移动到当前位置
						// self.toLocation(res)
						self.location.latitude = res.latitude;
						self.location.longitude = res.longitude;
						// uni.showToast({ title:'经纬度：'+self.location.latitude+self.location.longitude, icon: "none" })
						self.getAddress();
					}
				});
			},

			//逆地址解析，坐标到坐标所在位置的文字描述的转换
			getAddress() {
				qqmapsdk.reverseGeocoder({
					location: self.location || '', //获取表单传入的位置坐标,不填默认当前位置,示例为string格式
					//get_poi: 1, //是否返回周边POI列表：1.返回；0不返回(默认),非必须参数
					success: function(res) {
						// uni.showToast({ title:'res.result：'+res.result, icon: "none" })
						// console.log(self.searchKey);
						// console.log('允许授权:'+self.location.latitude+','+ self.location.longitude)
						self.location.address = res.result.address;
						// uni.showToast({ title:'地址：'+self.location.address, icon: "none" })
					},
					fail: function(res) {
						console.log(res);
						if (res.status == 120) {
							uni.showToast({
								title: "网络拥堵，请稍后...",
								icon: "none"
							})
						} else {
							uni.showToast({
								title: res.message,
								icon: "none"
							})
						}

					},
					complete: function(res) {
						console.log(res);
						// uni.showToast({ title:'complete：'+res, icon: "none" })
					}
				})
			},

			realSystime() {
				var now = new Date(); //创建Date对象
				var year = now.getFullYear(); //获取年份
				var month = now.getMonth() + 1; //获取月份
				var date = now.getDate(); //获取日期
				var day = now.getDay(); //获取星期
				var hour = now.getHours(); //获取小时
				var minu = now.getMinutes(); //获取分钟
				var sec = now.getSeconds(); //获取秒
				if (month >= 1 && month <= 9) {
					month = "0" + month;
				}
				if (date >= 0 && date <= 9) {
					date = "0" + date;
				}
				if (hour >= 0 && hour <= 9) {
					hour = "0" + hour;
				}
				if (minu >= 0 && minu <= 9) {
					minu = "0" + minu;
				}
				if (sec >= 0 && sec <= 9) {
					sec = "0" + sec;
				}
				var time = '' + year + month + date + hour + minu + sec;
				return time
			},


			// 新增图片
			// async afterRead(event) {
			// 	// 当设置 multiple 为 true 时, file 为数组格式，否则为对象格式
			// 	let lists = [].concat(event.file)
			// 	let fileListLen = this[`fileList${event.name}`].length
			// 	lists.map((item) => {
			// 		this[`fileList${event.name}`].push({
			// 			...item,
			// 			status: 'uploading',
			// 			message: '上传中'
			// 		})
			// 	})
			// 	for (let i = 0; i < lists.length; i++) {
			// 		const result = await this.uploadFilePromise(lists[i].url)
			// 		let item = this[`fileList${event.name}`][fileListLen]
			// 		this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
			// 			status: 'success',
			// 			message: '',
			// 			url: result
			// 		}))
			// 		fileListLen++
			// 	}
			// 	// console.log(this.fileList1)
			// },
			// uploadFilePromise(url) {
			// 	return new Promise((resolve, reject) => {
			// 		let a = uni.uploadFile({
			// 			url: uni.$http.baseUrl + 'fileUpload/', // 仅为示例，非真实的接口地址
			// 			filePath: url,
			// 			name: 'myfile',
			// 			formData: {
			// 				goodsid: this.goodsid,
			// 				imagevalue: this.imagevalue,
			// 			},
			// 			success: (res) => {
			// 				// var meta = JSON.parse(res.data);
			// 				// this.imagelist.push(meta.url)
			// 				// self.imagecheck = false
			// 				setTimeout(() => {
			// 					resolve(JSON.parse(res.data))
			// 				}, 1000)
			// 			}
			// 		});
			// 	})
			// },
			async cha() {
				const dataPost = {
					goodsid: this.goodsid,
					userid: uni.getStorageSync('userid'),

				}
				const {
					data: res
				} = await uni.$http.post('getGoodsDetail/', dataPost)
				if (res.code == 200) {

					this.typevalue = res.data.type;
					this.productModelValue = res.data.type;
					this.money = res.data.money;
					this.goodsname = res.data.goodsname;
					this.goodsdetail = res.data.goodsdetail;
					this.remnant = res.data.goodsdetail.length;
					this.goodstype = res.data.goodstype;
					this.changetest(res.data.goodstype)
					for (var i = 0; i < res.data.imagelist.length; i++) {

						this.fileList1.push({
							// url: this.mediaUrl + res.data.imagelist[i]
							url: res.data.imagelist[i]
						});
					}
					// _this3.fileList1 = JSON.parse(res.goods.imagelist);
					console.log('查询数据', res)
					this.image = this.fileList1[0];
					this.location.address = res.data.address;
					this.location.latitude = res.data.latitude;
					this.location.longitude = res.data.longitude;
					this.$refs.upload.fileList = this.fileList1

					console.log('查询数据', this.$refs?.upload.fileList)

				}

			},

			dialogToggle(type) {
				this.msgType = type
				this.$refs.alertDialog.open()
			},

			locationClick() {
				self.getLocationInfo();
			},

			async imageMsgCheck(postmsg, i) {
				const {
					data: res
				} = await uni.$http.post('publishImageMsgCheck/', postmsg)
				if (res.status == 200) {
					self.traceidList.push(res.trace_id)
				} else {
					console.log(res.msg)
				}
			},

			// textChange(e) {
			// 	console.log(e)
			// 	self.textcheck = false
			// 	// const o = e.target;

			// 	e = e.replace(/[^\u4E00-\u9FA5|\d|\a-zA-Z|\r\n\s,.?!，。？！…—&$=()-+/*{}[\]]/g, '')
			// 	this.$nextTick(() => {
			// 		this.goodsname = e;
			// 	});
			// },

			async goodsPublish(postmsg, i) {
				// console.log('goodsPublish')
				let fileList = this.$refs?.upload.fileList
				// console.log(fileList)
				// var imagelists = fileList.map((item) => `/media/${ item.url.split('/media/')?.[1] }`)
				// var imagelists1 = this.fileList1
				var imagelists= []
				console.log(imagelists)


				for (let i = 0; i < fileList.length; i++) {
					imagelists.push(fileList[i]['url'])

					// if (imagelists[i]['url'].indexOf('undefined') >= 0) {
					// 	console.log(imagelists[i])

					// 	// 证明有未上传的
					// 	self.isclick = true

					// 	return uni.showToast({
					// 		icon: 'error',
					// 		title: '稍等图片上传！',
					// 		duration: 2000
					// 	})
					// }
				}
				// console.log(this.typevalue)
				const dataPost = {
					username: this.userInfo.username,
					goodsid: this.goodsid,
					type: this.productModelValue,
					money: this.money,
					goodsname: this.goodsname,
					goodsdetail: this.goodsdetail,
					imagelist: imagelists,
					// goodstype: this.typevalue,
					goodstype: '其他',
					latitude: this.location.latitude,
					longitude: this.location.longitude,
					address: this.location.address,
				}
				const {
					data: res
				} = await uni.$http.post('goodsUpload/', dataPost)
				if (res.code == 200) {
					uni.showToast({
						icon: 'success',
						title: '商品发布成功了！',
						duration: 2000
					})
					setTimeout(function() {
						uni.reLaunch({
							url: '/pages/home/home'
						})
					}, 2000);

				} else {
					uni.showToast({
						icon: 'error',
						title: '请求失败！' + res.msg
					})
				}
			},
			// async getcheckResult() {
			// 	clearInterval(self.timer);
			// 	self.timer = setInterval(async () => {
			// 		console.log('setInterval---', self.timer)
			// 		const postmsg = {
			// 			traceidList: self.traceidList
			// 		}
			// 		const {
			// 			data: res
			// 		} = await uni.$http.post('publishImageMsgCheckResult/', postmsg)
			// 		if (res.status == 400) {
			// 			clearInterval(self.timer);
			// 			uni.hideLoading();
			// 			uni.showToast({
			// 				icon: 'fail',
			// 				title: '有违禁图片'
			// 			})
			// 		} else if (res.status == 200) {
			// 			self.imagecheck = true
			// 			console.log('res.msg200---', res.msg)
			// 			self.goodsPublish()
			// 			uni.hideLoading();
			// 			clearInterval(self.timer);
			// 		} else {
			// 			console.log('res.status==300', res.msg)
			// 		}
			// 		console.log('setInterval---', res)
			// 	}, 2000);
			// },
			// btnOkClickSure(){
			// 	this.showPopupOrder = false
			// 	if (this.istui == true) {
			// 		console.log('推')
			// 		// 判断用户是否设置了消息推送
			// 		wx.requestSubscribeMessage({
			// 			tmplIds: ['cmq1V_xcpONCouOIIXOj9rAitVjoza93k8gIWCtrX1c'],
			// 			success(res) {
			// 				console.log(res.cmq1V_xcpONCouOIIXOj9qRUDsqwrugjNvxn3trmhgk)
			// 				self.goodsPublish()
			// 			}
			// 		})

			// 	} else {
			// 		console.log('不推')
			// 		self.goodsPublish()
			// 		this.btnOkClickSure()
			// 	}
			// },
			btnOkClick() {
				// console.log(this.productModelValue)
				if (self.isclick) {
					let fileList = this.$refs?.upload.fileList
					// let fileList = this.fileList1
					// if (this.goodsname == '' || this.goodsdetail == '' || fileList.length == 0) {
					if (this.goodsdetail == '' || fileList.length == 0) {
						self.isclick = true
						uni.showToast({
							icon: 'none',
							// title: '商品名称，简介,以及图片不能为空',
							title: '简介,以及图片不能为空'
						})
						return null;
					} else
						// if (this.goodsname.length > 10) {
						// 	self.isclick = true
						// 	uni.showToast({
						// 		icon: 'none',
						// 		title: '名称字数请小于10'
						// 	})
						// 	return null;
						// } else
						if (this.goodsdetail.length > 50) {
							self.isclick = true
							uni.showToast({
								icon: 'none',
								title: '简介请控制在50字以内'
							})
							return null;
						} else
					if (Number(this.money) < 1) {
						self.isclick = true
						uni.showToast({
							icon: 'none',
							title: this.productModelValue !== 2 ? '贡献值必须大于0金币' : '售卖价格必须大于0元',
						})
						return null;
					}

					self.isclick = false;
					// console.log(this.istui)
					// this.showPopupOrder = true
					// if (this.istui == true) {
					// 	console.log('推')
					// 	// 判断用户是否设置了消息推送
					wx.requestSubscribeMessage({
						tmplIds: ['cmq1V_xcpONCouOIIXOj9rAitVjoza93k8gIWCtrX1c'],
						success(res) {
							console.log(res.cmq1V_xcpONCouOIIXOj9qRUDsqwrugjNvxn3trmhgk)
							self.goodsPublish()
						}
					})

					// } else {
					// 	console.log('不推')
					// 	self.goodsPublish()
					// 	this.btnOkClickSure()
					// }


				}
			},
		}
	}
</script>

<style lang="scss">
	.distance {
		font-size: 20rpx;
		color: #888889;

	}

	page {
		background-color: #ffffff;
	}

	.pd100 {
		padding-bottom: 100rpx !important;
	}

	textarea {
		min-height: 200rpx;
		text-align: left !important;
		padding: 20rpx;
		background-color: #F8F8FF;
		border-radius: 12rpx;
		box-sizing: border-box;
		color: #AEAEAE;
		font-size: 28rpx;
		width: 70vw;
		word-wrap: break-word;
		white-space: pre-line;
	}

	.show_number {
		position: absolute;
		bottom: 30rpx;
		right: 10rpx;
		color: #AEAEAE;
		font-size: 10px;
	}

	.item {
		position: relative;
		padding: 10rpx 0 !important;

		.position-address {
			min-height: 100rpx;
		}

		.key {
			color: #313131;
			font-size: 28rpx;
		}

		.ml30 {
			margin-left: 30rpx;
		}

		.value {
			text-align: left !important;
			font-size: 28rpx !important;
			padding-left: 20rpx;
			margin-left: 30rpx;
			color: #AEAEAE !important;
		}

		.value-box {
			width: 200rpx;

			input {
				background-color: #F1F1F1;
				text-align: center !important;
				margin-right: 10rpx;
			}

		}

		.placeholder {
			color: #AEAEAE;
			font-size: 28rpx;
		}

		input {
			border-radius: 34rpx;
			background: rgb(248, 248, 255);
			padding: 10rpx 20rpx;
			font-size: 28rpx;
		}

		&.flex-colum {
			.key {
				padding-bottom: 20rpx;
			}

			.image-box {
				padding-left: 0;
			}
		}

		.typeselectbox {
			display: flex;
			justify-content: space-between;
			align-items: center;
			text-align: center;
			position: relative;

			.icon {
				position: absolute;
				right: 40rpx;
				bottom: 10rpx;

				image {
					width: 18rpx;
					height: 18rpx;
				}
			}

			uni-data-select {
				width: 260rpx;
				color: #000;
			}

			.uni-select {
				border-radius: 34px;
				border: 1px solid rgb(191, 196, 242);
				height: 56rpx;

				.uni-select__input-box {
					height: 56rpx;
				}

				.uni-select__selector {
					width: 240rpx;
					position: absolute;
					top: calc(100% + 10rpx);
					left: 20rpx;
					color: #5553AA;
					padding: 0 20rpx;
					z-index: 5;

					.uni-popper__arrow {
						left: 75%
					}

					.uni-select__selector-item {
						text-align: center;
						border-bottom: 1rpx solid #BDC3FE;

						text {
							width: 90%;
						}

						&:last-child {
							border-bottom: none;
						}
					}
				}
			}

			.uni-select__input-text {
				color: #5553AA;
				transform: translateX(-20rpx);
				font-size: 24rpx;
			}

			.uni-icons {
				display: none;
			}
		}

		.radio {
			margin-right: 20rpx;
		}
	}

	.locationbtn {
		margin-bottom: 20rpx;
		margin-left: 150rpx;

		button {
			background-color: #58A4EC;
			border-radius: 43px;
		}

	}

	.btnbox {
		position: absolute;
		z-index: 0;
		bottom: 20px;
		// background-color: aqua;
		width: 100%;
		height: 60px;
		display: flex;

		.btnOk {
			width: 90%;
			align-self: center;
		}
	}

	.line {
		height: 1rpx;
		background: rgb(233, 235, 254);
		margin-bottom: 18rpx;
		width: 520rpx;
		margin-left: calc(100% - 520rpx);
	}

	.popup {
		box-sizing: border-box;
		width: 560rpx;
		padding: 30rpx 56rpx 50rpx;
		margin: 0 auto;
		color: #5553AA;
		position: relative;

		//height: 50vh;
		//overflow: scroll;
		.fixedTop {
			position: fixed;
			background: #fff;
			height: 50vh;
			width: 480rpx;
		}

		.titles {
			color: #5553AA;
			text-align: center;
			font-size: 28rpx;
			line-height: 2;
			font-weight: bold;
		}

		image {
			width: 28rpx;
			position: absolute;
			right: 30rpx;
			top: 30rpx;
		}

		text {
			font-size: 24rpx;
			line-height: 2;
			letter-spacing: 3rpx;
		}
	}

	.u-safe-area-inset-bottom {
		padding-bottom: 0 !important;
	}
</style>
